<?php

class Comment extends Article {

	var $id_comment;
	var $title;
	var $description;
	
	var $user;
	
	/////////////////////////////////////////////////
	// Static member methods
	
	function Comment($id_comment = -1, $complete = false) {
		global $site;
		$this->_table_name = "articles";
		$this->_site = $site;
		$this->_object_type = "comment";
		$this->_db = new mysqlconn(HOST,USER,PASS,DB);
		$this->_meta_fields = array("email");	
		$this->_alias_fields = array("id_article" => "id_comment", "title" => "name", "content" => "comment");

		if ($id_comment != -1) {
			$this->load($id_comment);
		}
	}
	
	function create($name, $content, $id_parent, $email) {
		$comment = new Comment();
		$comment->name = $name;
		$comment->comment = $content;		
		$comment->email = $email;
		$comment->id_parent = $id_parent;
		return $comment->save();
	}
	
	function create_logged($comment, $id_parent, $user) {
		$comment = new Comment();
		$comment->comment = $comment;		
		$membresy = new Membresy();
		$user = User::get_current();
		$comment->save();
		$comment = $comment->get_most_recent();
		$user->add_membresy($comment,1);
	}

	//////////////////////////////////////////////////////////////////////////////
	// Instance member methods

	///////////////////////////////////////////////////////////////////////////////
	// Polymorphism methods
	function get_instance($id_instance) {
		return new Comment($id_instance);
	}

	
}

?>